package com.joinway.framework.admin.core.service.file;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.joinway.framework.admin.core.utils.VelocityProcessor;

@Service
public class FileRepository implements IFileRepository<String> {

	private final static Logger log = LoggerFactory.getLogger(FileRepository.class);
	
	private final static String HTML_KEY = "html";
	
	private final static String NOTICE_TEMPLATE = "template/notice.html";
	
	@Autowired VelocityProcessor processor;
	
	@Override
	public void save(String file, String html) throws Exception {
		Map<String, Object> model = new HashMap<>();
		model.put(HTML_KEY, html);
		processor.process(NOTICE_TEMPLATE, model, file);
	}
	
}

